package me.zhengjie.inter.rest;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import me.zhengjie.annotation.Log;
import me.zhengjie.aop.annotation.BisLog;
import me.zhengjie.business.domain.Whfa;
import me.zhengjie.business.domain.Zhsq;
import me.zhengjie.business.service.WhfaFfxService;
import me.zhengjie.business.service.WhfaService;
import me.zhengjie.business.service.dto.WhfaFfxQueryCriteria;
import me.zhengjie.business.service.dto.WhfaQueryCriteria;
import me.zhengjie.inter.service.MpWhfaService;
import me.zhengjie.inter.service.MpZhsqService;
import me.zhengjie.utils.PageUtil;
import org.springframework.data.domain.Pageable;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;

/**
 * @author xiahongbo
 * @date 2022-07-10
 **/
@RestController
@RequiredArgsConstructor
@Api(tags = "移动端维护服务项目")
@RequestMapping("/mp/plan")
public class MpWhfaController {

    private final MpWhfaService mpWhfaService;
    private final WhfaService whfaService;
    private final WhfaFfxService whfaFfxService;
/*

    @PostMapping
    @Log("移动端新增照护方案")
    @ApiOperation("移动端新增照护方案")
    public ResponseEntity<Object> createZhfa(@Validated @RequestBody Whfa resources){

        return new ResponseEntity<>(PageUtil.toMpContent(mpWhfaService.create(resources)), HttpStatus.CREATED);
    }
*/

    @PostMapping
    @Log("移动端新增照护方案")
    @ApiOperation("移动端新增照护方案")
    public ResponseEntity<Object> createZhfa(@Validated @RequestBody Whfa whfa, @RequestParam String whrqs){

        return new ResponseEntity<>(PageUtil.toMpContent(mpWhfaService.create(whfa, whrqs)), HttpStatus.CREATED);
    }

    @PostMapping(value = "/updateZhfa")
    @Log("移动端修改照护方案")
    @ApiOperation("移动端修改照护方案")
    public ResponseEntity<Object> updateZhfa(@Validated @RequestBody Whfa whfa){

        return new ResponseEntity<>(PageUtil.toMpContent(mpWhfaService.update(whfa)), HttpStatus.CREATED);
    }

    @GetMapping(value = "/deleteZhfa")
    @Log("移动端删除照护方案")
    @ApiOperation("移动端删除照护方案")
    public ResponseEntity<Object> deleteZhfa(@Validated @RequestParam String id){
        mpWhfaService.delete(id);
        return new ResponseEntity<>(PageUtil.toMpContent(new HashMap<String,Object>()), HttpStatus.OK);
    }

    @GetMapping
    @Log("移动端查询照护方案")
    @ApiOperation("移动端查询照护方案")
    public ResponseEntity<Object> queryZhfa(WhfaQueryCriteria criteria, Pageable pageable){

        return new ResponseEntity<>(PageUtil.toMpContent(whfaService.queryMpAll(criteria, pageable)), HttpStatus.CREATED);
    }

    @GetMapping(value = "/fajh")
    @Log("移动端查询方案计划")
    @ApiOperation("移动端查询方案计划")
    public ResponseEntity<Object> queryFajh(WhfaFfxQueryCriteria criteria){
        return new ResponseEntity<>(PageUtil.toMpContent(whfaFfxService.queryAll(criteria)), HttpStatus.CREATED);
    }
}
